﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.Core.Values.TradeRefund
{
    /// <summary>
    /// 交易退款申请基本信息
    /// </summary>
    /// <typeparam name="TValueObject">值对象</typeparam>
    public class TradeRefundApplyBase<TValueObject> : AValueObject<TValueObject> 
        where TValueObject: TradeRefundApplyBase<TValueObject>
    {
        /// <summary>
        /// 应用Id   
        /// </summary>
        [StringLength(36)]
        public string AppId { get; set; }      

        /// <summary>
        /// 申请单号
        /// </summary>
        [Required]
        [StringLength(maximumLength: 32)]
        public string ApplyNo { get; set; }

        /// <summary>
        /// 订单号
        /// </summary>
        [Required]
        [StringLength(maximumLength: 64)]
        public string OrderNo { get; set; }

        /// <summary>
        /// 申请金额
        /// </summary>
        [Range(0.01, (double)decimal.MaxValue, ErrorMessage = "申请金额必须大于零")]
        public decimal ApplyMoney { get; set; }
        
        /// <summary>
        /// 原因
        /// </summary>
        public string Reason { get; set; }       

        /// <summary>
        /// 比较两个对象
        /// </summary>
        /// <param name="other">对象</param>
        /// <returns></returns>
        public sealed override bool Equals(TValueObject other)
        {
            if (other == null)
            {
                return false;
            }
            return string.Compare(other.AppId, this.AppId, false) == 0
                && string.Compare(other.ApplyNo, this.ApplyNo, false) == 0;
        }
    }
}
